#!/bin/bash

# 完整构建脚本，包括依赖检查和打包

set -e

PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_DIR"

echo "Checking for required tools..."
for tool in cmake make debuild; do
    if ! command -v $tool &> /dev/null; then
        echo "Error: $tool is not installed."
        exit 1
    done
done

echo "Checking for required libraries..."
if ! pkg-config --exists libpsutil; then
    echo "Error: libpsutil development files not found."
    exit 1
fi

if ! pkg-config --exists Qt5Core Qt5Widgets; then
    echo "Error: Qt5 development files not found."
    exit 1
fi

echo "All dependencies satisfied."

echo "Building project..."
./scripts/build-deb.sh

echo "Build process completed."